package com.dyit.config;

import com.dyit.job.CheckUsernameJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyQuartzConfig {
    @Bean
    public JobDetail jobDetail(){
        return JobBuilder
                .newJob(CheckUsernameJob.class)//the class name which would be executed
                .withIdentity("my-job-test-id")
                .storeDurably(true)
                .build();
    }

    @Bean
    public Trigger jobTrigger(){
        return TriggerBuilder
                .newTrigger()
                .forJob("my-job-test-id")
                .withSchedule(
                        CronScheduleBuilder
                        .cronSchedule("0/5 * * * * ? *"))
                .build();
    }
}
